// Copyright 2008 The Closure Library Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS-IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
 * @fileoverview Default renderer for {@link goog.ui.Button}s.
 *
 * @author attila@google.com (Attila Bodis)
 */

goog.provide('mp.ui.GLayoutElmRenderer');

goog.require('goog.dom.a11y');
goog.require('goog.dom.a11y.Role');
goog.require('goog.ui.ControlRenderer');

goog.require('goog.graphics.ext');

/**
 * Default renderer for {@link goog.ui.Button}s.  Extends the superclass with
 * the following button-specific API methods:
 * <ul>
 *   <li>{@code getValue} - returns the button element's value
 *   <li>{@code setValue} - updates the button element to reflect its new value
 *   <li>{@code getTooltip} - returns the button element's tooltip text
 *   <li>{@code setTooltip} - updates the button element's tooltip text
 *   <li>{@code setCollapsed} - removes one or both of the button element's
 *       borders
 * </ul>
 * For alternate renderers, see {@link goog.ui.NativeButtonRenderer},
 * {@link goog.ui.CustomButtonRenderer}, and {@link goog.ui.FlatButtonRenderer}.
 * @constructor
 * @extends {goog.ui.ControlRenderer}
 */
mp.ui.GLayoutElmRenderer = function() {
  goog.base(this);
};
goog.inherits(mp.ui.GLayoutElmRenderer, goog.ui.ControlRenderer);
goog.addSingletonGetter(mp.ui.GLayoutElmRenderer);


/**
 * Default CSS class to be applied to the root element of components rendered
 * by this renderer.
 * @type {string}
 */
mp.ui.GLayoutElmRenderer.CSS_CLASS = goog.getCssName('mp-glayoutelm');


/**
 * Returns the ARIA role to be applied to buttons.
 * @return {goog.dom.a11y.Role|undefined} ARIA role.
 * @override
 */
mp.ui.GLayoutElmRenderer.prototype.getAriaRole = function() {
  return undefined; //goog.dom.a11y.Role.GRIDCELL;
};

/** @override */
mp.ui.GLayoutElmRenderer.prototype.decorate = function(control, element) {
  // The superclass implementation takes care of common attributes
  element = goog.base(this, 'decorate', control, element);
  return element;
};

mp.ui.GLayoutElmRenderer.prototype.getKeyEventTarget = function(control) {
  return control.getGElement().getWrapper().getElement();
};

/** @override */
mp.ui.GLayoutElmRenderer.prototype.getCssClass = function() {
  return mp.ui.GLayoutElmRenderer.CSS_CLASS;
};